package dao

import (
	"zg3zk3/inits"
	"zg3zk3/model"
)

func CreateQun(userId int) (err error) {
	tx := inits.DB.Begin()
	result := &model.Qun{
		UserId: userId,
	}
	if err = inits.DB.Create(&result).Error; err != nil {
		return err
	}
	hhh := &model.QunUser{
		UserId: userId,
		Types:  1,
		RoomId: int(result.ID),
	}
	if err = inits.DB.Create(&hhh).Error; err != nil {
		return err
	}
	tx.Commit()
	return nil

}
